#!/bin/bash -e

function info() {
echo Usage: `basename $0` '[-n  num_site_max] beta_test'
exit 1
}

while getopts  ":p:f:n:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
        n) nf_new=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 1 ]; then info; fi

. $var

b450k_no_name=$data_path/meth/b450k.no_name.txt
names=$data_path/meth/b450k.names.txt
ids=$data_path/meth/450k.id.npy
nf_new=${nf_new:=10000}

cat $1|cut -f1 > $out_prefix.ids_test.txt

feature_single.py  $out_prefix.ids_test.txt $ids $out_prefix.nf_test.txt

# ids_sub450.py $ids $out_prefix.ids_test.txt $nf_new $out_prefix.nf_test.txt
dos2unix $out_prefix.nf_test.txt

nf=`awk '{print NF; exit 0}' $b450k_no_name`
echo $nf

file_name=''
j=0
for nf in `cat $out_prefix.nf_test.txt`; do
    ((j+=1))
    cut -f $nf $b450k_no_name > $out_prefix.b450k.sub.test.${j}.txt
    file_name="$file_name $out_prefix.b450k.sub.test.${j}.txt"
done

paste $names $file_name > $out_prefix.b450k.sub.test.txt
rm $file_name

. $cmd_done